package eoeProject.edenOfEast.core;

import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.apache.wicket.util.file.File;

public class ThumbMaker {

	public static void graphics2d() {
		try {
			int width = 100;
			int height = 100;
			FileInputStream fis;

			fis = new FileInputStream("img/top_about.jpg");

			BufferedImage image = ImageIO.read(fis);
			fis.close();
			BufferedImage shrinkImage = new BufferedImage(width, height,
					image.getType());
			Graphics2D g2d = shrinkImage.createGraphics();
			g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
					RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
			g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
					RenderingHints.VALUE_ANTIALIAS_ON);
			g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
					RenderingHints.VALUE_COLOR_RENDER_QUALITY);
			g2d.setRenderingHint(RenderingHints.KEY_DITHERING,
					RenderingHints.VALUE_DITHER_ENABLE);
			g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
					RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
			g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
					RenderingHints.VALUE_RENDER_QUALITY);
			g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
					RenderingHints.VALUE_INTERPOLATION_BILINEAR);
			g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
					RenderingHints.VALUE_FRACTIONALMETRICS_ON);
			g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
					RenderingHints.VALUE_STROKE_NORMALIZE);
			g2d.drawImage(image, 0, 0, width, height, null);
			ImageIO.write(shrinkImage, "jpg", new File("img/top_about2.jpg"));
		} catch (FileNotFoundException e) {
			System.out.println("ThumbMakerException: " + e.getMessage());
		} catch (IOException e) {
			System.out.println("ThumbMakerException: " + e.getMessage());
		}
	}

}
